<?php

namespace App\Http\Controllers\Backend\Report;

use App\ConstDir\ErrorConst;
use App\Http\Controllers\Backend\BaseController;
use App\Repository\Repositories\Interfaces\ReportRepository;
use Illuminate\Http\Request;
use Prettus\Repository\Criteria\RequestCriteria;

/**
 * 举报管理
 *
 * @package App\Http\Controllers\Report
 */
class ReportController extends BaseController
{
	/**
	 * @var ReportRepository
	 */
	protected $report_repo;


	public function __construct(ReportRepository $report_repo, Request $request)
	{
		$this->report_repo = $report_repo;
	}

	public function index()
	{
		$report = $this->report_repo->paginate($this->perPage);
		return $this->success(ErrorConst::SUCCESS_CODE, $report, true);
	}

	public function update(Request $request)
	{
		$this->validate($request, [
			'status' => 'required',
			'id' =>'required'
		]);
		$data = $request->all();
		$ret = $this->report_repo->update(['status'=> $data['status']], $data['id']);
		if ($ret) {
			return $this->success(ErrorConst::SUCCESS_CODE, ErrorConst::SUCCESS_CODE_MSG);
		} else {
			return $this->error(ErrorConst::FAILED_CODE);
		}
	}

	public function delete($id)
	{
		//删除现在没有，不实现
//		$ret = $this->change_repo->delete($id);
//
//		if ($ret) {
			return $this->success(ErrorConst::SUCCESS_CODE, ErrorConst::SUCCESS_CODE_MSG);
//		} else {
//			return $this->error(ErrorConst::FAILED_CODE);
//		}
	}
}
